package com.atguigu.tingshu.album.mapper;

import com.atguigu.tingshu.model.album.AlbumInfo;
import com.atguigu.tingshu.query.album.AlbumInfoQuery;
import com.atguigu.tingshu.vo.album.AlbumListVo;
import com.atguigu.tingshu.vo.album.AlbumStatVo;
import com.atguigu.tingshu.vo.album.AlbumTrackListVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface AlbumInfoMapper extends BaseMapper<AlbumInfo> {
    //SQL语句演变
    //select id as albumId,album_title,cover_url,include_track_count,is_finished,status from album_info
    //
    //        select if(stat_type='0401',stat_num,0) playStatNum from album_stat
    //        select if(stat_type='0402',stat_num,0) subscribeStatNum from album_stat
    //        select if(stat_type='0403',stat_num,0) buyStatNum from album_stat
    //        select if(stat_type='0404',stat_num,0) albumCommentStatNum from album_stat

    //        select
    //            max(if(stat_type='0401',stat_num,0)) playStatNum,max(if(stat_type='0402',stat_num,0)) subscribeStatNum,
    //               max(if(stat_type='0402',stat_num,0)) buyStatNum, max(if(stat_type='0404',stat_num,0)) albumCommentStatNum
    //        from album_stat group by album_id = #{albumId}

    //        select ai.id as albumId,ai.album_title,ai.cover_url,ai.include_track_count,ai.is_finished,ai.status,
    //            max(if(ast.stat_type='0401',stat_num,0)) playStatNum,max(if(ast.stat_type='0402',stat_num,0)) subscribeStatNum,
    //               max(if(ast.stat_type='0402',stat_num,0)) buyStatNum, max(if(ast.stat_type='0404',stat_num,0)) albumCommentStatNum
    //        from album_info ai left join
    //         album_stat ast on ast.album_id = ai.id  where ai.user_id = #{vo.userId}  group by ai.id
//
    Page<AlbumListVo> getUserAlbumPage(@Param("pageInfo") Page<AlbumListVo> pageInfo,@Param("vo") AlbumInfoQuery albumInfoQuery);

    AlbumStatVo getAlbumStatVo(Long albumId);
    /**
     * 查询指定专辑下包含声音列表
     *
     * @param pageInfo
     * @param albumId
     * @return
     */
    Page<AlbumTrackListVo> getAlbumTrackPage(Page<AlbumTrackListVo> pageInfo, @Param("albumId") Long albumId);


    void updateAlbumStat(@Param("statType") String statType,@Param("albumId") Long albumId,@Param("count") Integer count);
}
